package top.bug.blog.controller.backend;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.bug.blog.annotation.Auth;
import top.bug.blog.entity.dto.common.BatchRequest;
import top.bug.blog.common.Result;
import top.bug.blog.entity.dto.tag.TagAddRequest;
import top.bug.blog.entity.dto.tag.TagQueryRequest;
import top.bug.blog.entity.dto.tag.TagUpdateRequest;
import top.bug.blog.entity.po.Tag;
import top.bug.blog.service.TagService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author <a href="https://github.com/jiusi66">九思.</a>
 * @email 10837907@qq.com
 * @from <a href="https://www.52bug.top">递归茶馆-www.52bug.top</a>
 * @description 后台-标签模块
 */
@Api(tags = "标签管理模块")
@RestController
@RequestMapping("/tagApi")
@Auth
public class TagController {
    @Resource
    private TagService tagService;

    @PostMapping("/getList")
    @ApiOperation("获取列表")
    public Result<Page<Tag>> getList(@RequestBody TagQueryRequest queryRequest) {
        return Result.success(tagService.getList(queryRequest));
    }

    @PostMapping("/getByIds")
    @ApiOperation("批量查询")
    public Result<List<Tag>> getByIds(@RequestBody BatchRequest batchRequest) {
        return Result.success(tagService.getByIds(batchRequest));
    }

    @PostMapping("/add")
    @ApiOperation("新增数据")
    public Result<Boolean> add(@RequestBody TagAddRequest addRequest) {
        return Result.success(tagService.add(addRequest));
    }

    @PostMapping("/edit")
    @ApiOperation("编辑数据")
    public Result<Boolean> edit(@RequestBody TagUpdateRequest updateRequest) {
        return Result.success(tagService.edit(updateRequest));
    }

    @PostMapping("/delete")
    @ApiOperation("删除数据")
    public Result<Boolean> delete(@RequestBody BatchRequest batchRequest) {
        return Result.success(tagService.delete(batchRequest));
    }

}